package cn.jathlon.datastructure;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.TreeSet;

/**
* Primarily intended for use in MultiMaps, the CollectionFactory defines a
* single method which returns a Collection. Implementations are provided for a
* number of standard Collections and the programmer can implement his own
* versions of this factory.
*
* @author chris
*
* @param <V>
*/
public abstract class CollectionFactory<V> {
 
        public abstract Collection<V> newCollection();
 
        static class ArrayListFactory<V> extends CollectionFactory<V> {
                @Override
                public Collection<V> newCollection() {
                        return new ArrayList<V>();
                }
        }
 
        public static class linkedListFactory<V> extends CollectionFactory<V> {
                @Override
                public Collection<V> newCollection() {
                        return new LinkedList<V>();
                }
        }
 
        public static class HashSetFactory<V> extends CollectionFactory<V> {
                @Override
                public Collection<V> newCollection() {
                        return new HashSet<V>();
                }
        }
 
        public static class LinkedHashSetFactory<V> extends CollectionFactory<V> {
                @Override
                public Collection<V> newCollection() {
                        return new LinkedHashSet<V>();
                }
        }
 
        public static class TreeSetFactory<V> extends CollectionFactory<V> {
                @Override
                public Collection<V> newCollection() {
                        return new TreeSet<V>();
                }
        }
 
 
 
}